package cn.xshi.sys.service.impl;
import java.util.List;
import java.util.Map;
import cn.xshi.sys.form.SysVersionForm;
import cn.xshi.sys.service.SysVersionService;
import cn.xshi.sys.dao.SysVersionDao;
import cn.xshi.sys.model.SysVersion;
import org.springframework.stereotype.Service;
import cn.xshi.common.base.BaseService;
import cn.xshi.common.util.ExceptionUtil;
import javax.annotation.Resource;
/**
 * @Desc 平台版本
 * @Author 邓纯杰
 * @CreateTime 2012-12-12 12:12:12
 */
@Service
public class SysVersionServiceImpl extends BaseService implements SysVersionService {

	@Resource
	private SysVersionDao sysVersionDao;

	/**
	 * 分页
	 * @param sysVersionForm
	 * @return
	 */
	public List<SysVersion> getSysVersionListByCondition(SysVersionForm sysVersionForm){
		try{
			return sysVersionDao.getSysVersionListByCondition(sysVersionForm);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	 * 查询对象
	 * @param id
	 * @return
	 */
	public SysVersion getSysVersionById(String id){
		try{
			SysVersion sysVersion = sysVersionDao.getSysVersionById(id);
			return sysVersion;
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
	}

	/**
	 * 添加
	 * @param sysVersion
	 * @return
	 */
	public int addSysVersion(SysVersion sysVersion){
		int i = 0;
		try {
			sysVersion.setCreateId(getCurrentAccountId());
			sysVersion.setCreateTime(getDate());
			i = sysVersionDao.addSysVersion(sysVersion);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 修改
	 * @param sysVersion
	 * @return
	 */
	public int updateSysVersion(SysVersion sysVersion){
		int i = 0;
		try {
			sysVersion.setUpdateId(getCurrentAccountId());
			sysVersion.setUpdateTime(getDate());
			i = sysVersionDao.updateSysVersion(sysVersion);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 修改（根据动态条件）
	 * @param sysVersion
	 * @return
	 */
	public int updateSysVersionBySelective(SysVersion sysVersion){
		int i = 0;
		try {
			sysVersion.setUpdateId(getCurrentAccountId());
			sysVersion.setUpdateTime(getDate());
			i = sysVersionDao.updateSysVersionBySelective(sysVersion);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}

	/**
	 * 删除
	 * @param condition
	 * @return
	 */
	public int delSysVersion(Map<String,Object> condition){
		int i = 0;
		try {
			i = sysVersionDao.delSysVersion(condition);
		} catch (Exception e) {
			throw new ExceptionUtil(e.getMessage(),e.getCause());
		}
		return i;
	}
}

